package module_five.task03.ClientModel;

import module_five.task03.ClientScanner;

import java.io.Serializable;
import java.util.HashSet;

public class ClientStudentManager implements Serializable {

    private static final long serialVersionUID = -5631032210994836741L;

    /**
     * 添加一个学员
     * @return
     */
    public Student addStudent() {

        System.out.println("请输入学员学号:");
        int id = ClientScanner.getScanner().nextInt();

        System.out.println("请输入学员姓名:");
        String name = ClientScanner.getScanner().next();

        System.out.println("请输入学员年龄:");
        int age = ClientScanner.getScanner().nextInt();

        return new Student(id, name, age);
    }

    /**
     * 查询一个学员
     * @return
     */
    public Student selectStudent() {

        System.out.println("请输入学员学号:");
        int id = ClientScanner.getScanner().nextInt();

        return new Student(id);
    }

    /**
     * 删除一个学员
     * @return
     */
    public Student deleteStudent() {

        System.out.println("请输入要删除的学员的学号:");
        int id = ClientScanner.getScanner().nextInt();

        return new Student(id);
    }

    /**
     * 修改一个学员
     * @return
     */
    public Student modifyStudent() {

        System.out.println("请输入要修改的学员的学号(学号不存在则无法修改):");
        int id = ClientScanner.getScanner().nextInt();

        System.out.println("请输入要修改的学员的姓名:");
        String name = ClientScanner.getScanner().next();

        System.out.println("请输入要修改的学员的年龄:");
        int age = ClientScanner.getScanner().nextInt();

        return new Student(id, name, age);
    }

    public static void main(String[] args) {

        HashSet<Student> hashSet = new HashSet<>();

        Student stu1 = new Student(1, "1", 1);
        boolean b1 = hashSet.add(stu1);
        System.out.println(b1);
        Student stu2 = new Student(1, "1", 1);
        b1 = hashSet.add(stu2);
        System.out.println(b1);
    }


}
